<?php
$pageTitle = '添加链接';
include 'header.tpl.php'; ?>
<script type="text/javascript">
$(document).ready(function(){
	$('#newtype').toggle(function(){
		$(this).html('不创建新分类');
		$('#typeid').val(0);
		$('#typeid').hide();
		$(this).next('input').show();
	},function(){
		$(this).html('新分类');
		$('#typeid').show();
		$(this).next('input').val('');
		$(this).next('input').hide();
	})
	$('#up-logo').upload(
			{
				field: 'logo'
			}
	);
})
</script>

<fieldset>
<legend>添加链接</legend>
		<form action="<?php echo $short_router;?>add" method="post">
		<ul>
		<li><label>分类</label>
			<select name="typeid" id="typeid">
			<option value="0">请选择分类</option>
			<?php foreach ($linkTypes as $type):?>
			<option value="<?php echo $type['id'];?>" <?php if ($link['typeid']==$type['id']):?>selected="selected"<?php endif;?>><?php echo $type['name'];?></option>
			<?php endforeach;?>
			</select>
			<a href="javascript:void();" id="newtype">新分类</a>
			<input type="text" name="typename" style="display:none" />
		</li>
		<li><label>名称</label><input type="text" name="name" value="<?php echo $link['name'];?>" /></li>
		<li><label>链接</label><input type="text" name="url" value="<?php echo $link['url'];?>" /></li>
		<li><label>LOGO</label><input type="text" name="logo" id="logo" value="<?php echo $link['logo'] ? APP_HOST . $link['logo'] : '';?>" />
		<span id="up-logo" class="button">上传</span>
		<span class="button" onclick="window.open(document.getElementById('logo').value);">&nbsp;预览</span>
		</li>
		
		<li><label>显示顺序</label><input type="text" name="priority" value="<?php echo $link['priority'] ? $link['priority'] : 100;?>" /></li>
		<li><button type="submit">提交</button> <button type="reset">清空</button>
		<input type="hidden" name="act" value="<?php echo isset($act) ? $act : 'add';?>" />
		<input type="hidden" name="id" value="<?php echo $link['id'];?>" />
		</li>
		</ul>
		</form>
</fieldset>

<?php include 'footer.tpl.php';?>